package com.springcloud.system.user.config;

import com.springcloud.system.user.interceptor.SystemUserInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * <p>  </p>
 *
 * @author mori
 * @since 11/7/2019 4:19 PM
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    private SystemUserInterceptor systemUserInterceptor;

    public WebConfig(SystemUserInterceptor systemUserInterceptor) {
        this.systemUserInterceptor = systemUserInterceptor;
    }

    @Bean
    public HandlerInterceptor userInterceptor() {
        return systemUserInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userInterceptor());
    }
}
